package com.meisupic.copyright.support;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * creation wuxun
 *
 * @version V1.0
 * @Description: TODO
 * @date 2018/1/14 13:11
 */
@Data
@ApiModel
public class Message<T> {

  @ApiModelProperty(value = "操作是否成功")
  private boolean success;

  @ApiModelProperty(value = "错误码")
  private Integer code;

  @ApiModelProperty(value = "错误信息")
  private String message;

  private T data;

  private Message(boolean success, Integer code, String message, T data) {
    this.success = success;
    this.code = code;
    this.message = message;
    this.data = data;
  }


  public static Message success(Object data) {
    return new Message(true, 0, null, data);
  }

  public static Message error(String message) {
    return new Message(false, 1, message, null);
  }
}
